import org.springframework.util.concurrent.ListenableFuture;

import javax.sound.midi.Soundbank;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class test {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入参数1");
        String val1 = scanner.next();
        System.out.println("输入参数2");
        String val2 = scanner.next();
//        String val1="演员-李连杰|周杰伦;歌手-周杰无|周杰伦;歌曲-青花瓷|双截棍;电影-青蜂侠|英雄";
//        String val2="双截棍是周杰伦演唱的一首歌曲，由方文山作词。";
        ArrayList<String> key = new ArrayList<>();
        String[] split1 = val1.split(";");
        HashMap<String, List<String>> map = new HashMap<>();
        for (String s : split1) {
            String[] split2 = s.split("-");
            for (int i = 0; i < split2.length; i++) {
                if (i%2==0){
                    key.add(split2[i]);
                    map.put(split2[i],null);
                }else {
                    String[] split = split2[i].split("\\|");
                    ArrayList<String> value = new ArrayList<>();
                    for (String s1 : split) {
                        value.add(s1);
                    }
                    map.put(split2[i-1],value);
                }
            }
        }
        StringBuffer buffer = new StringBuffer(val2);
        for (String key1 : map.keySet()) {
            List<String> list = map.get(key1);
            for (String value : list) {

                if (val2.contains(value)){
                    int index = buffer.indexOf(value);
                    buffer.insert(index+value.length(),"/"+key1+" ");
                    if (index!=0){
                        buffer.insert(index," ");
                    }
                }
            }
        }
//        System.out.println(map);
        System.out.println(buffer);
    }
}
